package util;

import java.util.Scanner;

/**
 * Created by 李雨昂 on 2019/7/27.
 */
public class PrintCalendar {
    public static void main(String[] args) {
        //1.创建Scanner对象
        Scanner sc = new Scanner(System.in);
        System.out.print("请您输入年份:>");
        int year = sc.nextInt();

        System.out.print("请您输入月份:>");
        int month = sc.nextInt();

        System.out.print("请您输入日:>");
        int day = sc.nextInt();
        printCalendar(year,month,day);

    }
    public static void printCalendar(int year,int month,int day){
        //写代码...

        //1.求某个月的最大天数
        int maxDay = DateUtil.getMaxDays(2015,9);

        //求某天是某个星期的第几天
        int dayOfWeek = DateUtil.getDayOfWeeks(year,month,1);

        //3.获取今天是几号
        int date = DateUtil.getDay();

        System.out.println("========="+year+"年"+month+"月=========");
        System.out.println("日\t一\t二\t三\t四\t五\t六");

        //定义一个计数器,用来控制换行
        int count = 0;

        for (int i = 0; i < dayOfWeek; i++) {
            System.out.print("\t");
            count++;
        }
        for (int i = 1; i <= maxDay; i++) {
            if(i == date){
                System.out.print(i+"*\t");
            }else{
                System.out.print(i+"\t");
            }
            count++;
            if (count == 7){
                System.out.println();
                count = 0;
            }
        }
    }
}
